Fix agent task workspace change normalization - #1790
Merged
Conversation
The executor previously carried four independent cleanup sites for the private runtime source root and the runner workspace seed snapshot: mid-run awaits, an inline catch-path duplicate, a partial exit hook, and signal handlers that cleaned only one of the two resources and exited 128 for every signal. Replace them with a single idempotent module-level coordinator that claims both roots exactly once and chains repeat invocations onto the in-flight cleanup instead of racing it. The top-level normal and failure paths route through one finally; SIGINT/SIGTERM/SIGHUP await the same coordinator before exiting with the conventional 128+signum code; the process exit hook keeps a bounded synchronous best-effort fallback for abrupt exits. Error reporting and redaction are preserved, and stderr messages are now redacted while the private root is still known. A deterministic interruption test starts the executor in a child process, pauses it immediately after seed snapshot creation through a narrowly scoped NODE_ENV=test marker-file hook that is inert in production, delivers each signal, and asserts the temp seed snapshot directory is removed, the conventional exit code is set, and no runner workspace content survives. A normal run in the same harness proves routine cleanup still passes.
This was referenced Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1788
Summary
Cleanup coordinator (final blocker)
.github/scripts/run-agent-task/execute-native-agent-task.mjs(mid-run awaits, an inline catch-path duplicate, a partialexithook covering only the runtime source root, and signal handlers that cleaned only one resource and exited128for every signal).tests/execute-native-agent-task-interruption.test.mjsdeterministically starts the executor in a child process, pauses it immediately after seed snapshot creation via a narrowly scopedNODE_ENV=testmarker-file hook (inert in production), delivers SIGTERM/SIGINT/SIGHUP, and asserts the temp seed snapshot directory is removed, the exit code is 143/130/129 respectively, and no runner workspace content survives; a normal run in the same harness proves routine cleanup still passes.tests/runtime-sources-materialization.test.tspins the coordinator shape: one coordinator definition, signal handlers routed through it, a single top-levelfinally, and no duplicate independent cleanup logic. Error reporting/redaction is preserved (stderr failure messages are now redacted while the private root is still known).How to test
npm run build.npm run test:agent-task-contracts.npm run test:native-agent-task-playground-e2e.npm run test:native-agent-task-interruptionand confirm it reportsnative agent task interruption okafter exercising SIGTERM, SIGINT, and SIGHUP plus a normal completion.native agent task Playground e2e ok; it verifies hostREADME.mdapplication, publication projection, canonical refs, empty typed artifacts, prepared workspace mounts, snapshot exclusions, and redaction.Backwards compatibility
AI assistance